<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/jstl/c" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/jstl/fn" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>邮件群发列表</title>
<style type="text/css">
.vb_wid {width:100%; margin: 0 auto; border-top:1px #FDB18D solid; background:#F5F5F5; color:#FE6500; text-indent:20px; line-height:25px; font-size:12px;}
.fb_search {width:90%; margin:0 auto; margin-top:20px; border:1px #FFCD7F solid;}
.fb_search h1 {background:#FFEFBB; margin:0px; padding:0px; line-height:28px; text-indent:10px; font-size:14px;}
.fb_s_a1 {margin:5px; font-size:14px; line-height:30px;}
.fb_s_a2 {font-size:12px; line-height:22px; color:#999; margin-left:5px;}
.fb_ddd {width:90%; margin:0 auto; margin-top:10px; border-top:3px #FFCC00 solid; background:url(images/pen.gif) no-repeat 5px 3px; height:40px; text-indent:50px; line-height:40px; color:#464646; font-size:12px;}
.fb_nr {width:90%; margin:0 auto; margin-top:10px; line-height:22px; font-size:12px; color:#464646}
.fb_nr span {color:#FF0000;}
.fb_nr select {color:464646; font-size:12px;}
.fb_nr Div {margin-top:10px; height:30px;}
.fb_nr Div input {font-size:12px; line-height:18px;}
.inputtttt {border:1px #DEA303 solid; height:20px; color:#464646; font-size:12px; background:url(images/bottom_bg.jpg) repeat-x left top;}
.lb {background:#FFCD7F; color:#464646; font-weight:bold; text-align:center; height:30px; line-height:30px;}
.lb1 {border-bottom:1px #000000 dashed; height:28px;}
.lb1 td {border-bottom:1px #ccc dashed; background:#eefefe}
.fy1 {width:90%; margin:0 auto; margin-top:8px; background:#F8F8F8; font-size:12px; height:30px; line-height:28px; text-indent:10px;}
.fy1 span {color:#FF0000; font-weight:bold;}
.fy1 a {color:#464646; text-decoration:none;}
.fy1 a:hover {color:#FF0000; text-decoration:underline;}

.fuj {width:90%; margin: 0 auto; font-size:12px; color:#464646; line-height:26px; border:1px #989898 solid; padding:5px;}
</style>

<script type='text/javascript' src='/dwr/interface/CountryAreaSelect.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>


<script type="text/javascript">
function getAllProv() {
    CountryAreaSelect.getAllProvinces(provSelectOptions);
 }
 
 function getCiytByProvId(provID){
    CountryAreaSelect.getAllCitiesByProvinceId(provID,citySelectOptions);
 }
 
 /***
 function getDiquByCityId(cityID){
    CountryAreaSelect.getAllDiquesByCityId(cityID,diquSelectOptions);
 }
 ****/
 
 function provSelectOptions(provList){
     DWRUtil.removeAllOptions("provId");
     DWRUtil.addOptions("provId", provList);   
 }
 
 function citySelectOptions(cityList){
      DWRUtil.removeAllOptions("cityId"); 
      DWRUtil.addOptions("cityId", {'-1':'请选择'}); 
      DWRUtil.addOptions("cityId", cityList); 
 }
 
 /****
  function diquSelectOptions(diquList){
      DWRUtil.removeAllOptions("diquid");
      DWRUtil.addOptions("diquid", {'-2':'请选择'}); 
      DWRUtil.addOptions("diquid", diquList); 
 }
 ****/
 
 function getProvSelected(selectObj){
       for(var i = 0; i < selectObj.options.length; i++){
	       if (selectObj.options[i].selected){
	         var id = selectObj.options[i].value;
	          getCiytByProvId(id);
	       }
       }
 }
 
  /**
  function getCitySelected(selectObj){
       for(var i = 0; i < selectObj.options.length; i++){
	       if (selectObj.options[i].selected){
	         var id = selectObj.options[i].value;
	          getDiquByCityId(id);
	       }
       }
 }
 **/
 
 //开始搜索
 function startSearch()
 {
    var link='/admin/manage/adminSendEmailSearch.do?action=search';
    var form=document.forms['adminSendEmailSearchForm'];
    var userName = form.userName.value;
    var userType = form.userType.value;
    var userGrade = form.userGrade.value;
    var provId = form.provId.value;
    var cityId = form.cityId.value;
    var isAudite = form.isAudite.value;
    var isCommend = form.isCommend.value;
    var isDel = form.isDel.value;
    
    if(userName!='')
    {
      link=link+'&userName='+userName;
    }
    
    if(userType!='' && userType!='-1')
    {
      link = link +'&userType='+userType;
    }
    
    if(userGrade!=''  && userGrade!='-1')
    {
      link = link + '&userGrade='+userGrade;
    }
    
    if(provId!=''  && provId!='-1')
    {
      link = link + '&provId='+provId;
    }
    
     if(cityId!=''  && cityId!='-1')
    {
      link = link + '&cityId='+cityId;
    }
    
    
     if(isAudite!=''  && isAudite!='-1')
    {
      link = link + '&isAudite='+isAudite;
    }
    
     if(isCommend!=''  && isCommend!='-1')
    {
      link = link + '&isCommend='+isCommend;
    }
    
     if(isDel!=''  && isDel!='-1')
    {
      link = link + '&isDel='+isDel;
    }
    
    window.location.href=encodeURI(link);
 }
 
 function selectAll(choice) {
   if(document.forms['adminSendEmailSearchForm'].checkboxparam.length!=null)
   {
	   for (var i=0;i<document.forms['adminSendEmailSearchForm'].checkboxparam.length;i++) 
	   {
			var e=document.forms['adminSendEmailSearchForm'].checkboxparam[i];
			if(choice==1)e.checked=true;
			if(choice==2)e.checked=(e.checked?false:true);
			if(choice==3)e.checked=false;
		}
   }
   
   //单个的处理
   else
   {
     var e=document.forms['adminSendEmailSearchForm'].checkboxparam;
     if(choice==1)e.checked=true;
			if(choice==2)e.checked=(e.checked?false:true);
			if(choice==3)e.checked=false;
     
   }
	
}
 
 
 //群发短信息
 function sendEbbEmailToAll()
 {
   var param = '';
   var flag = 0;
   var link='/admin/manage/adminSendEmailSearch.do?action=dealWithAll&mailType=note';
   var searchLink='/admin/manage/adminSendEmailSearch.do?action=search';
   var toPageLink=document.getElementById('toPageLink').value;
   var curPage = document.getElementById('curPage').value;
   var title = document.getElementById('title').value;
   var content = document.getElementById('content').value;
   var forms=document.forms['adminSendEmailSearchForm'];
   if(forms.checkboxparam.length!=null)
   {
           for (var i=0;i<forms.checkboxparam.length;i++) 
		   {
		        var e=forms.checkboxparam[i];
		        if(e.checked)
		        {
					param += '&checkboxparam=' + e.value;
					flag = 1;
				}
		   }
		   if(flag==1)
		   {
		   //alert(link+param+toPageLink+'&page='+curPage+'&title='+title+'&content='+content);
		      window.location=encodeURI(link+param+toPageLink+'&page='+curPage+'&title='+title+'&content='+content);
		   }
		   else
		   {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
   //只选择了一项
   else if(forms.checkboxparam!=null)
   {
       var e=forms.checkboxparam;
        if(e.checked)
        {
					param += '&checkboxparam=' + e.value;
					flag = 1;
	    }
	    
	      if(flag==1)
		   {
		       window.location=encodeURI(link+param+toPageLink+searchLink+'&page='+curPage+'&title'+title+'&content='+content);
           }
           else
           {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
 }
 
 
 
 //群发邮件
 function sendEmailToAll()
 {
   var param = '';
   var flag = 0;
   var link='/admin/manage/adminSendEmailSearch.do?action=dealWithAll&mailType=email';
   var searchLink='/admin/manage/adminSendEmailSearch.do?action=search';
   var toPageLink=document.getElementById('toPageLink').value;
   var curPage = document.getElementById('curPage').value;
   var title = document.getElementById('title').value;
   var content = document.getElementById('content').value;
   var forms=document.forms['adminSendEmailSearchForm'];
   if(forms.checkboxparam.length!=null)
   {
           for (var i=0;i<forms.checkboxparam.length;i++) 
		   {
		        var e=forms.checkboxparam[i];
		        if(e.checked)
		        {
					param += '&checkboxparam=' + e.value;
					flag = 1;
				}
		   }
		   if(flag==1)
		   {
		      window.location=encodeURI(link+param+toPageLink+'&page='+curPage+'&title='+title+'&content='+content);
		   }
		   else
		   {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
   
   //只选择了一项
   else if(forms.checkboxparam!=null)
   {
       var e=forms.checkboxparam;
        if(e.checked)
        {
					param += '&checkboxparam=' + e.value;
					flag = 1;
	    }
	    
	      if(flag==1)
		   {
		       window.location=encodeURI(link+param+toPageLink+searchLink+'&page='+curPage+'&title'+title+'&content='+content);
           }
           else
           {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
 }
 
 var control;
 var page;
 function toPage(control,page)
 {
   var searchLink='/admin/manage/adminSendEmailSearch.do?action=search';
   var toPageLink=document.getElementById('toPageLink').value;
   var toPageValue = document.getElementById('toPageValue').value;
   var link='';
   
    if(control!='toPage')
    {
       link=searchLink+toPageLink+'&page='+page;
    }
    else
    {
       link=searchLink+toPageLink+'&page='+toPageValue;
    }
    
    window.location=encodeURI(link);
 }
 
 
      function hiddenuserGrade(){
        var userType=document.getElementById("userType").value;
        if(userType=='gr'){
        var userGrade=document.getElementById("userGrade");
        userGrade.style.display="none";
        }
        else {
            var userGrade=document.getElementById("userGrade");
            userGrade.style.display="block";
          }

    }
 
 
</script>
</head>

<body>
<div class="vb_wid">&nbsp;【邮件群发列表】</div>

<html:form action="/admin/manage/adminSendEmailSearch.do?action=search">
<div class="fb_search">
   <h1>搜索</h1>
  <div class="fb_s_a1">
   
    <label>用户名:
     <input type="text" id="userName" name="userName" size="10" />
    </label>
    <label>
    用户类型:
    <html:select property="userType" onchange="hiddenuserGrade();">
      <html:option value="-1">请选择</html:option>
      <html:option value="gr">个人</html:option>
      <html:option value="zst">招商通</html:option>
      <html:option value="wgt">网购通</html:option>
    </html:select>
     <html:select property="userGrade">
      <html:option value="-1">请选择</html:option>
      <html:option value="0">普通</html:option>
      <html:option value="1">银牌</html:option>
      <html:option value="2">金牌</html:option>
    </html:select>
    省份城市：
   <html:select property="provId" onchange="getProvSelected(this);">
    <html:option value="-2" >请选择</html:option>
    <logic:present name="provList">
    <logic:iterate id="item" name="provList">
    <option value="${item.provId }" <c:if test="${provId==item.provId }">selected</c:if> >${item.prov}</option>
    </logic:iterate>
    </logic:present>
    </html:select>
    -
    <html:select property="cityId" value="${cityId}" >
    <html:option value="-2" >请选择</html:option>
    <c:if test="${cityMap!=null}">
	      <html:optionsCollection name="cityMap" label="value" value="key"/>
	</c:if>
    </html:select>
    <br />
    是否审核:
   <html:select property="isAudite"> 
     <html:option value="-1">请选择</html:option>
     <html:option value="0">否</html:option>
     <html:option value="1">是</html:option>
   </html:select>
    
    是否推荐:
   <html:select property="isCommend"> 
     <html:option value="-1">请选择</html:option>
     <html:option value="0">否</html:option>
     <html:option value="1">是</html:option>
   </html:select>
   
    是否删除:
   <html:select property="isDel"> 
     <html:option value="-1">请选择</html:option>
     <html:option value="0">否</html:option>
     <html:option value="1">是</html:option>
   </html:select>
    
    <input  type="button" id="tijiao" value="搜索" onclick="startSearch();"/>
    </label>
    
  </div>
   <div class="fb_s_a2">注：搜索条件可以输入多个，中间用逗号&quot;，&quot;隔开</div>
</div>
<div class="fb_nr">
  <table width="100%" border="0" cellspacing="1">
    <tr class="lb">
      <td width="5%">选择</td>
      <td width="9%" title="用户名">用户名</td>
      <td width="20%" title="企业名称/个人真名">名称</td>
      <td width="10%">是否审核</td>
      <td width="12%">是否推荐</td>
      <td width="15%" title="招商通(金)">用户等级</td>	  
      <td width="13%">省份/城市</td>
      <td width="16%">注册时间</td>
    </tr>
    
    <%-- 个人类型 --%>
  <c:if test="${adminSendEmailSearchForm.userType!=null  && adminSendEmailSearchForm.userType!='gr' && qiyeinfoList!=null}">
  <c:forEach items="${qiyeinfoList}" var="qiyeinfoList" varStatus="qiyeinfoListSts">
    <tr class="lb1">
     <td align="center"><label>
         <input type="checkbox" id="checkboxparam" name="checkboxparam" value="${qiyeinfoList.qiyejibiao.userid}" />
      </label></td>
      <td align="center">${qiyeinfoList.qiyejibiao.cpUsername}</td>
      <td align="center">${qiyeinfoList.qiyejibiao.cpName}</td>
      <td align="center"><c:if test="${qiyeinfoList.qiyejibiao.ifCheck!='1'}">☆</c:if> <c:if test="#{qiyeinfoList.qiyejibiao.ifCheck=='1'}">★</c:if></td>
      <td align="center"><c:if test="${qiyeinfoList.qiyejibiao.isCommend!='1'}">☆</c:if> <c:if test="#{qiyeinfoList.qiyejibiao.isCommend=='1'}">★</c:if></td>
      <td align="center">
         <c:if test="${qiyeinfoList.qiyejibiao.attractBusinessManType == '1'}">
            招商通
            <c:if test="${qiyeinfoList.qiyejibiao.attractBusinessManGrade == '1'}">(银)</c:if>
            <c:if test="${qiyeinfoList.qiyejibiao.attractBusinessManGrade == '2'}">(金)</c:if>
         </c:if>
         
         <c:if test="${qiyeinfoList.qiyejibiao.saleBusinessManType == '1'}">
            网购通
            <c:if test="${qiyeinfoList.qiyejibiao.gradeclass == '1'}">(银)</c:if>
            <c:if test="${qiyeinfoList.qiyejibiao.gradeclass == '2'}">(金)</c:if>
         </c:if>
      </td>
      <td align="center"><c:if test="${qiyeinfoList.prov!=null}">${qiyeinfoList.prov.prov}</c:if>
      <c:if test="${qiyeinfoList.city!=null}">${qiyeinfoList.city.city}</c:if></td>
      <td align="center">${qiyeinfoList.qiyejibiao.regtime}</td>
    </tr>
    </c:forEach>
  </c:if>
  
   <%-- 企业类型 --%>
   <c:if test="${adminSendEmailSearchForm.userType!=null  && adminSendEmailSearchForm.userType=='gr'}">
   <c:forEach items="${gerenbiaoList}" var="gerenbiaoList" varStatus="gerenbiaoListSts">
    <tr class="lb1">
     <td align="center"><label>
        <input type="checkbox" id="checkboxparam" name="checkboxparam" value="${gerenbiaoList.GUserid}" />
      </label></td>
      <td align="center">${gerenbiaoList.GYonghum}</td>
      <td align="center">${gerenbiaoList.turename}</td>
      <td align="center">
      </td>
      <td align="center"><c:if test="${gerenbiaoList.iscommend!='1'}">☆</c:if>
      <c:if test="${gerenbiaoList.iscommend!='1'}">★</c:if></td>
      <td align="center"></td>
      <td align="center"><c:if test="${gerenbiaoList.prov!=null}">${gerenbiaoList.prov.prov}</c:if>
      <c:if test="${gerenbiaoList.city!=null}">${gerenbiaoList.city.city}</c:if></td>
      <td align="center">${gerenbiaoList.addtime}</td>
    </tr>
  </c:forEach>
  </c:if>
    
	<tr>
      <td colspan="13"><div><label>
      <html:button onclick="selectAll(1);" property="button" value="全选" />
		&nbsp;
		<html:button onclick="selectAll(2);" property="button" value="反选" />
						&nbsp;
	<html:button onclick="selectAll(3);" property="button" value="不选" />
	<html:button onclick="javascript:sendEmailToAll();void 0" property="button" value="群发邮件"/>
	<html:button onclick="javascript:sendEbbEmailToAll();void 0" property="button" value="群发短信息"/>
      </label>
          <label></label>
          <label></label>
          <label></label>
          <label></label>
          <label></label>
      </div></td>
    </tr>
  </table>
</div>
<input id="toPageLink" name="toPageLink" type="hidden"  value="&userType=${adminSendEmailSearchForm.userType}&userGrade=${adminSendEmailSearchForm.userGrade}&provId=${adminSendEmailSearchForm.provId}&cityId=${adminSendEmailSearchForm.cityId}&isAudite=${adminSendEmailSearchForm.isAudite}&isCommend=${adminSendEmailSearchForm.isCommend}&isDel=${adminSendEmailSearchForm.isDel}" />
<input id="curPage" name="curPage" type="hidden" value="${curPage}"/>
<div class="fy1">

  	<logic:notEmpty name="recordNum">
	<c:if test="${recordNum>0}">
		<c:if test="${curPage>1}">
		     <html:link href="javascript:toPage(before,${backPage}); void 0;" >上一页</html:link>
		</c:if>
		<%--  页码循环 --%>
		<c:if test="${(curPage>=1)&&(curPage<=7)&&(allPage<8)}">
		<c:forEach begin="${1}" end="${allPage}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${(curPage>=1)&&(curPage<=7)&&(allPage>8)}">
		<c:forEach begin="${1}" end="${8}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${curPage>7&&(allPage>(curPage+4))}">
		 <html:link href="javascript:toPage('curPage',1); void 0;" >1</html:link>....
		<c:forEach begin="${(curPage-3)}" end="${(curPage+4)}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${curPage>7&&(allPage<=(curPage+4))}">
         <html:link href="javascript:toPage('curPage',1); void 0;" >1</html:link>....
		<c:forEach begin="${(curPage-3)}" end="${allPage}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>

			<c:if test="${curPage<allPage}">
			<html:link href="javascript:toPage('curPage',${nextPage}); void 0;" >下一页</html:link>
			</c:if>
            <c:if test="${(allPage>1)&&(curPage<allPage)}">
             <html:link href="javascript:toPage('curPage',${allPage}); void 0;" >尾页</html:link>   
			</c:if>
	</c:if>
	</logic:notEmpty>        
               

                到
                 <input id="toPageValue"  name="toPageValue" type="text" size="2"/>
    页&nbsp;
      <input type="button"  value=" " style="background-image: url('/admin/images/ck.gif');border:0px;width:58px;"  title="查看"  onclick="return toPage('toPage','toPage');"/>
    
</div>
<div class="fuj">
  <table width="100%" border="0">
    <tr>
      <td width="10%">主题:</td>
      <td width="90%"><label>
        <html:text property="title" size="30"></html:text>
      </label></td>
    </tr>
    <tr>
      <td>内容:</td>
      <td><label>
        <html:text property="content" size="80"></html:text>
      </label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
</html:form>

</body>
</html>
